from selenium import webdriver
import ddt
import unittest
from selenium.webdriver.common.by import By
from readder15 import readzsmc
import time

# 数据驱动和unittest一起用
# 给类名加上@ddt.ddt
@ddt.ddt
class Denglu(unittest.TestCase):
    def setUp(self):
        self.driver = webdriver.Chrome()
        self.driver.implicitly_wait(5)
    def tearDown(self):
        self.driver.quit()

    stream_info = readzsmc()

    # 给方法名加上@ddt.data(*数据)注释
    @ddt.data(*stream_info)
    def test_denglu(self,list):  # 方法参数带上list，数据驱动的每一次测试都是1个list,list表示表格里的一行

        driver = self.driver
        driver.get("http://192.168.46.5:18089/login")
        driver.find_element(By.NAME,'username').send_keys("XTGLY")
        driver.find_element(By.CLASS_NAME,'password').send_keys("123456")
        driver.find_element(By.ID,"signIn").click()
        driver.find_element(By.PARTIAL_LINK_TEXT,"仓库信息").click()
        time.sleep(2)
        driver.find_element(By.XPATH,'//*[@id="store_name"]').send_keys(list[0])  # 方法里用list[0]下标引用具体单元格的值
        driver.find_element(By.XPATH,'//*[@id="store_query"]').click()

if __name__ == '__main__':
    unittest.main()